package com.pansoft.openplanet.manager;

import com.efounder.utils.ResStringUtil;
import com.pansoft.openplanet.R;
import com.pansoft.openplanet.bean.MarketSiteBean;
import com.utilcode.util.SPUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 市场交易所等管理
 * @author will
 */
public class MarketExchangeSiteManager {

    public static List<MarketSiteBean> getMarketSiteList() {

        List<MarketSiteBean> list = new ArrayList<>();
        MarketSiteBean marketSiteBean = new MarketSiteBean.Builder().uniqueKey("bkindex")
                .title(ResStringUtil.getString(R.string.op_market_all_net)).url("https://bitkan.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/bkindex.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean1 = new MarketSiteBean.Builder().uniqueKey("okex.com")
                .title("OKEX").url("https://www.okex.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/okex-com.png")
                .isSelected(false).build();
//        MarketSiteBean marketSiteBean2 = new MarketSiteBean.Builder().uniqueKey("bitmex")
//                .title("BitMEX").url("https://www.bitmex.com")
//                .logo("https://static.bitkan.com/static/img/sites/64x64/bitmex.png")
//                .isSelected(false).build();
        MarketSiteBean marketSiteBean3 = new MarketSiteBean.Builder().uniqueKey("zb")
                .title("ZB.com").url("https://www.zb.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/zb.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean4 = new MarketSiteBean.Builder().uniqueKey("binance")
                .title(ResStringUtil.getString(R.string.op_market_binance)).url("https://www.binance.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/binance.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean5 = new MarketSiteBean.Builder().uniqueKey("bithumb")
                .title("Bithumb").url("https://www.bithumb.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/bithumb.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean6 = new MarketSiteBean.Builder().uniqueKey("huobi.future")
                .title("火币合约").url("https://www.hbdm.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/huobi-future.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean7 = new MarketSiteBean.Builder().uniqueKey("lbank")
                .title("LBank").url("https://www.lbank.info")
                .logo("https://static.bitkan.com/static/img/sites/64x64/lbank.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean8 = new MarketSiteBean.Builder().uniqueKey("huobi.pro")
                .title("火币全球站").url("https://www.hbg.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/huobi-pro.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean9 = new MarketSiteBean.Builder().uniqueKey("coinbene")
                .title("CoinBene").url("https://www.coinbene.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/coinbene.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean10 = new MarketSiteBean.Builder().uniqueKey("bw.com")
                .title("BW.com").url("https://www.bw.com/")
                .logo("https://static.bitkan.com/static/img/sites/64x64/bw-com.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean11 = new MarketSiteBean.Builder().uniqueKey("hitbtc")
                .title("HitBTC").url("https://hitbtc.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/hitbtc.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean12 = new MarketSiteBean.Builder().uniqueKey("exx")
                .title("EXX").url("https://www.exx.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/exx.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean13 = new MarketSiteBean.Builder().uniqueKey("coinnice")
                .title("Coinnice").url("http://www.coinnice.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/coinnice.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean14 = new MarketSiteBean.Builder().uniqueKey("cex.com")
                .title("CEX.COM").url("http://www.cex.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/cex-com.png")
                .isSelected(false).build();
        MarketSiteBean marketSiteBean15 = new MarketSiteBean.Builder().uniqueKey("bit-z")
                .title("Bit-Z").url("https://www.bit-z.com")
                .logo("https://static.bitkan.com/static/img/sites/64x64/bit-z.png")
                .isSelected(false).build();
        list.add(marketSiteBean);
        list.add(marketSiteBean1);
        list.add(marketSiteBean5);
        list.add(marketSiteBean3);
        list.add(marketSiteBean4);
//        list.add(marketSiteBean5);
//        list.add(marketSiteBean6);
//        list.add(marketSiteBean7);
//        list.add(marketSiteBean8);
//        list.add(marketSiteBean9);
//        list.add(marketSiteBean10);
//        list.add(marketSiteBean11);
//        list.add(marketSiteBean12);
//        list.add(marketSiteBean13);
//        list.add(marketSiteBean14);
//        list.add(marketSiteBean15);

        String siteKey = getCurrentMarketSite();
        for (int i = 0; i < list.size(); i++) {
            if (siteKey.equals(list.get(i).getUniqueKey())) {
                list.get(i).setSelected(true);
            } else {
                list.get(i).setSelected(false);
            }
        }
        return list;
    }

    /**
     * 设置当前的交易所，默认全网bkindex
     * @param site site
     */
    public static void setCurrentMarketSite(String site) {
        SPUtils.getInstance().put("opMarketSite", site);
    }

    public static void setCurrentMaketName(String name) {
        SPUtils.getInstance().put("opMarketSiteName", name);
    }

    /**
     * 获取当前的交易所site，默认全网bkindex
     * @return site
     */
    public static String getCurrentMarketSite() {
        return SPUtils.getInstance().getString("opMarketSite", "bkindex");
    }

    public static String getCurrentMaketName() {
        return SPUtils.getInstance().getString("opMarketSiteName",
                ResStringUtil.getString(R.string.op_market_all_net));
    }
}
